﻿using System.Web.Mvc;
using System.Timers;
using System.Web.Routing;
using Liber.WEB;
using Liber;

namespace AgileAgent
{
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            XMLSetting.SetDefault(Server.MapPath("") + "\\NodeConfig.cfg");
            
            //TODO:初始化应用的身份信息
            //var info = XMLSetting.DefaultSetting.First("OpenAPP");
            //LiberAgent.Ini(info.First("AppToken").Value, info.First("AppID").Value, info.First("AppSec").Value, XMLSetting.DefaultSetting.First("TLCloud").First("OpenAPI").Value);

            //每2小时主动推送新数据
            //Timer plan = new Timer(1200000);
            //plan.AutoReset = true;
            //plan.Elapsed += plan_Elapsed;
            //plan.Start();
        }

        /// <summary>
        /// 定时任务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //void plan_Elapsed(object sender, ElapsedEventArgs e)
        //{
        //    AgileAgent.Controllers.AgileAgentController aa = new Controllers.AgileAgentController();
        //    aa.AsyncPushData();
        //}
    }
}
